//
//  Player.m
//  UI_个人项目—播放器
//
//  Created by dlios on 15-8-21.
//  Copyright (c) 2015年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "Player.h"
#import "STKAudioPlayer.h"
#import "LJP_GuideCellModel.h"

//static Player *single = nil;
@implementation Player

+(Player *)share
{
    
    static Player *single = nil;
    if (single == nil) {
        single = [[Player alloc] init];
        single.num = -1;
    }
    return single;
}
-(void)playWithUrl:(NSURL *)url num:(NSInteger)num
{
    if (num == self.num) {
        
    }else{
    [self stop];
    self.player = [[STKAudioPlayer alloc] init];
    [self.player playURL:url];
        self.num = num;
    }
}
-(void)stop
{
    if (self.player) {
        [self.player stop];
    }
}
-(void)pause //暂停
{
    [self.player pause];
}
-(void)resume //播放
{
    [self.player resume];
}
-(void) mute //静音
{
    [self.player mute];
}
-(void) unmute //解除静音
{
    [self.player unmute];
}

-(void)qiege:(NSInteger)shu
{
    if (shu == self.listArray.count) {
        Player *playr = [Player share];
        [playr stop];
        [playr playWithUrl:[NSURL URLWithString:[self.listArray[0] playUrl64]] num:0];
        self.num = 0;

    }else{
        Player *playr = [Player share];
        [playr stop];
        [playr playWithUrl:[NSURL URLWithString:[self.listArray[shu] playUrl64]] num:shu];
        
        self.num = shu;
    }
}


@end
